//
//  JSTUserIconCell.m
//  KYKJPackDemo
//
//  Created by 01 on 17/6/19.
//  Copyright © 2017年 ???. All rights reserved.
//

#import "JSTUserIconCell.h"

@interface JSTUserIconCell ()

@property (nonatomic, strong) UILabel *label;

@property (nonatomic, strong) UIImageView *iconView;

@end

@implementation JSTUserIconCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    // Initialization code
}

- (id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        _label = [[UILabel alloc] init];
        [self addSubview:_label];
        
        _iconView = [[UIImageView alloc] init];
        [self addSubview:_iconView];
    }
    return self;
}

- (void)setIconImage:(UIImage *)iconImage
{
    _iconImage = iconImage;
}

- (void) createContent:(NSString *)str
{
    CGFloat iconW = kCurrentScreenWidth(50);
    CGFloat iconH = kCurrentScreenWidth(50);
    CGFloat iconX = kDeviceWidth - iconW - kCurrentScreenWidth(30);
    CGFloat iconY = EvaluationCellInset;
    _iconView.frame = CGRectMake(iconX, iconY, iconW, iconH);
    if (_iconImage)
    {
        _iconView.image = _iconImage;
    }else
    {
        [_iconView setImageWithURL:[NSURL URLWithString:str]];
    }
    
    _iconView.clipsToBounds = YES;
    _iconView.layer.cornerRadius = iconW/2.;
    
    CGFloat labelX = EvaluationCellInset;
    CGFloat labelY = EvaluationCellInset;
    CGSize size = [NSString sizeWithString:@"头像" font:kSystemFont(kCurrentScreenWidth(12)) CGsize:CGSizeMake(kDeviceWidth, MAXFLOAT)];
    _label.frame = CGRectMake(labelX, labelY, size.width, iconH);
    _label.text = @"头像";
    _label.font = kSystemFont(kCurrentScreenWidth(12));
    _label.textAlignment = NSTextAlignmentCenter;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
